﻿using ERP_RORZE_DLL.Product.Base;
using ERP_RORZE_DLL.Product.database;
using System;using ERP_RORZE_SYSTEM;
using System.Collections.Generic;
using System.Data;using ERP_RORZE_SYSTEM;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ERP_RORZE_DLL.Product.DAO
{
    public class ClsPartHandlingDAO: ExecuteSQL
    {
        ExecuteSQL Execute = new ExecuteSQL();
        public DataTable GetAllMachineHandDetail()
        {
            string sql = clsConstantsFuction.ClsFuctionDMachineHand.GetAll;
            return Execute.DoStoreProcedure(sql, true);
        }
        /// <summary>
        ///lấy danh sách MONo và danh sách StaffID
        /// </summary>
        /// <returns></returns>
        /// 
        /// 

        public DataTable GetAllMachineHandDetail(int range)
        {

            var parameters = new SqlParameter[]
                    {
						CreateParameter("@Range", SqlDbType.Int, range)
                    };
            //return ExcuteProcedure(ToolConstants.StoreProcedure.Broken.GetAllWithDateRange, parameters);

            string sql = clsConstantsFuction.ClsFuctionDMachineHand.GetAllWithRange; 

            return Execute.DoStoreGetByID(sql, parameters, true);


        }

        public DataTable GetlAllMONo()
        {
            string sql = clsConstantsFuction.ClsFuctionMO.GetAll1;
            return Execute.DoStoreProcedure(sql, true);
        }
        public DataTable GetlAllMONo1()
        {
            string sql = clsConstantsFuction.ClsFuctionMO.GetAllMH;
            return Execute.DoStoreProcedure(sql, true);
        }
        public DataTable GetlAllStaffID()
        {
            string sql = clsConstantsFuction.ClsFuctionStaff.GetAll;
            return Execute.DoStoreProcedure(sql, true);
        }
        /// <summary>
        /// lấy dữ liệu từ các bảng
        /// </summary>
        /// <returns></returns>

        public DataTable GetAllHandInspDetail()
        {
            string sql = clsConstantsFuction.ClsFuctionDHandInsp.GetAll;
            return Execute.DoStoreProcedure(sql, true);
        }
        public DataTable GetAllHandInspDetail(int range)
        {
            var parameters = new SqlParameter[]
                    {
						CreateParameter("@Range", SqlDbType.Int, range)
                    };
            //return ExcuteProcedure(ToolConstants.StoreProcedure.Broken.GetAllWithDateRange, parameters);

            string sql = clsConstantsFuction.ClsFuctionDHandInsp.GetAllWithRange;

            return Execute.DoStoreGetByID(sql, parameters, true);
        }

        public DataTable GetAllInspHandMisReturnDetail()
        {
            string sql = clsConstantsFuction.ClsFuctionDMInspHand.GetAll;
            return Execute.DoStoreProcedure(sql, true);
        }

        public DataTable GetAllHandInspMisReturnDetail()
        {
            string sql = clsConstantsFuction.ClsFuctionDMHandInsp.GetAll;
            return Execute.DoStoreProcedure(sql, true);
        }

        public DataTable GetAllBusInspDetail()
        {
            string sql = clsConstantsFuction.ClsFuctionDBusInsp.GetAll;
            return Execute.DoStoreProcedure(sql, true);
        }

        public DataTable GetAllInspBusMisReturnDetail()
        {
            string sql = clsConstantsFuction.ClsFuctionDMInspBus.GetAll;
            return Execute.DoStoreProcedure(sql, true);
        }

        public DataTable GetAllBusInspMisReturnDetail()
        {
            string sql = clsConstantsFuction.ClsFuctionDMBusInsp.GetAll;
            return Execute.DoStoreProcedure(sql, true);
        }

        public DataTable GetAllInspAnodDetail()
        {
            string sql = clsConstantsFuction.ClsFuctionDInspAnod.GetAll;
            return Execute.DoStoreProcedure(sql, true);
        }


        public DataTable GetAllInspAnodDetail(int range)
        {
            var parameters = new SqlParameter[]
                    {
						CreateParameter("@Range", SqlDbType.Int, range)
                    };
            //return ExcuteProcedure(ToolConstants.StoreProcedure.Broken.GetAllWithDateRange, parameters);

            string sql = clsConstantsFuction.ClsFuctionDInspAnod.GetAllWithRange;

            return Execute.DoStoreGetByID(sql, parameters, true);
        }

        public DataTable GetAllAnodQtyChangeDetail()
        {
            string sql = clsConstantsFuction.ClsFuctionAnodQtyChange.GetAll;
            return Execute.DoStoreProcedure(sql, true);
        }

        public DataTable GetAllAnodInspDetail()
        {
            string sql = clsConstantsFuction.ClsFuctionDAnodInsp.GetAll;
            return Execute.DoStoreProcedure(sql, true);
        }

        public DataTable GetAllAnodInspDetail(int range)
        {
            var parameters = new SqlParameter[]
                    {
						CreateParameter("@Range", SqlDbType.Int, range)
                    };
            //return ExcuteProcedure(ToolConstants.StoreProcedure.Broken.GetAllWithDateRange, parameters);

            string sql = clsConstantsFuction.ClsFuctionDAnodInsp.GetAllWithRange;

            return Execute.DoStoreGetByID(sql, parameters, true);
        }

        public DataTable GetAllInspF3Detail()
        {
            string sql = clsConstantsFuction.ClsFuctionDInspF3.GetAll;
            return Execute.DoStoreProcedure(sql, true);
        }

        public DataTable GetAllInspF3DetailRange(int range)
        {
            string sql = clsConstantsFuction.ClsFuctionDInspF3.GetAllRange;
            var parameters = new SqlParameter[]
                    {
						CreateParameter("@Range", SqlDbType.Int, range)
                    };
            return Execute.DoStoreGetByID(sql, parameters, true);

        }

        public DataTable GetAllF3StoreDetail()
        {
            string sql = clsConstantsFuction.ClsFuctionDF3Store.GetAll;
            return Execute.DoStoreProcedure(sql, true);
        }

        public DataTable GetAllF3StoreDetailRange(int range)
        {
            string sql = clsConstantsFuction.ClsFuctionDF3Store.GetAllRange;
            var parameters = new SqlParameter[]
                    {
						CreateParameter("@Range", SqlDbType.Int, range)
                    };
            return Execute.DoStoreGetByID(sql, parameters, true);
        }

        public void DeleteDAnodInspDetail(ClsDAnodInspTable b)
        {
            var parameter = new SqlParameter[]
                {
                    CreateParameter(clsConstantsSP.ClsDAnodInspSP.ID, SqlDbType.Int, b.ID)
                    
                };
            Execute.DoDelete(clsConstantsFuction.ClsFuctionDAnodInsp.Delete, parameter, true);

        }
        public void DeleteAnodQtyChangeDetail(clsAnodQtyChangeTable b)
        {
            var parameter = new SqlParameter[]
                {
                    CreateParameter(clsConstantsSP.ClsAnodQtyChangeSP.ID, SqlDbType.Int, b.ID)
                    
                };
            Execute.DoDelete(clsConstantsFuction.ClsFuctionAnodQtyChange.Delete, parameter, true);

        }
        public void DeleteBusInspDetail(ClsDBusInspTable b)
        {
            var parameter = new SqlParameter[]
                {
                    CreateParameter(clsConstantsSP.ClsDBusInspSP.ID, SqlDbType.Int, b.ID)
                    
                };
            Execute.DoDelete(clsConstantsFuction.ClsFuctionDBusInsp.Delete, parameter, true);

        }
        public void DeleteBusInspMisReturnDetail(ClsDMBusInspTable b)
        {
            var parameter = new SqlParameter[]
                {
                    CreateParameter(clsConstantsSP.ClsDMBusInspSP.ID, SqlDbType.Int, b.ID)
                    
                };
            Execute.DoDelete(clsConstantsFuction.ClsFuctionDMBusInsp.Delete, parameter, true);

        }
        public void DeleteF3StoreDetail(ClsDF3StoreTable b)
        {
            var parameter = new SqlParameter[]
                {
                    CreateParameter(clsConstantsSP.ClsDF3StoreSP.ID, SqlDbType.Int, b.ID)
                    
                };
            Execute.DoDelete(clsConstantsFuction.ClsFuctionDF3Store.Delete, parameter, true);

        }
        public void DeleteHandInspDetail(ClsDHandInspTable b)
        {
            var parameter = new SqlParameter[]
                {
                    CreateParameter(clsConstantsSP.ClsDHandInspSP.ID, SqlDbType.Int, b.ID)
                    
                };
            Execute.DoDelete(clsConstantsFuction.ClsFuctionDHandInsp.Delete, parameter, true);

        }
        public void DeleteHandInspMisReturnDetail(ClsDMHandInspTable b)
        {
            var parameter = new SqlParameter[]
                {
                    CreateParameter(clsConstantsSP.ClsDMHandInspSP.ID, SqlDbType.Int, b.ID)
                    
                };
            Execute.DoDelete(clsConstantsFuction.ClsFuctionDMHandInsp.Delete, parameter, true);

        }
        //DeleteHandInspStatus
        //public void DeleteHandInspStatus(ClsDHandInspTable b)
        //{
        //    var parameter = new SqlParameter[]
        //        {
        //            CreateParameter(clsConstantsSP.ClsDHandInspSP.ID, SqlDbType.Int, b.ID)
                    
        //        };
        //    Execute.DoDelete(clsConstantsFuction.ClsFuctionDHandInsp.Delete, parameter, true);

        //}
        public void DeleteInspAnodDetail(ClsDInspAnodTable b)
        {
            var parameter = new SqlParameter[]
                {
                    CreateParameter(clsConstantsSP.ClsDInspAnodSP.ID, SqlDbType.Int, b.ID)
                    
                };
            Execute.DoDelete(clsConstantsFuction.ClsFuctionDInspAnod.Delete, parameter, true);

        }
        public void DeleteInspBusMisReturnDetail(ClsDMInspBusTable b)
        {
            var parameter = new SqlParameter[]
                {
                    CreateParameter(clsConstantsSP.ClsDMInspBusSP.ID, SqlDbType.Int, b.ID)
                    
                };
            Execute.DoDelete(clsConstantsFuction.ClsFuctionDMInspBus.Delete, parameter, true);

        }
        public void DeleteInspF3Detail(ClsDInspF3Table b)
        {
            var parameter = new SqlParameter[]
                {
                    CreateParameter(clsConstantsSP.ClsDInspF3SP.ID, SqlDbType.Int, b.ID)
                    
                };
            Execute.DoDelete(clsConstantsFuction.ClsFuctionDInspF3.Delete, parameter, true);

        }
        public void DeleteInspHandMisReturnDetail(ClsDMInspHandTable b)
        {
            var parameter = new SqlParameter[]
                {
                    CreateParameter(clsConstantsSP.ClsDMInspHandSP.ID, SqlDbType.Int, b.ID)
                    
                };
            Execute.DoDelete(clsConstantsFuction.ClsFuctionDMInspHand.Delete, parameter, true);

        }
        public void DeleteMachineHandDetail(ClsDMachineHandTable b)
        {
            var parameter = new SqlParameter[]
                {
                    CreateParameter(clsConstantsSP.ClsDMachineHandSP.ID, SqlDbType.Int, b.ID)
                    
                };
            Execute.DoDelete(clsConstantsFuction.ClsFuctionDMachineHand.Delete, parameter, true);

        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="b"></param>
        public void InsertDAnodInspDetail(ClsDAnodInspTable b)
        {

            try
            {
                var parameter = new SqlParameter[]
                {
                    CreateParameter(clsConstantsSP.ClsDAnodInspSP.date, SqlDbType.DateTime, b.Date),
                    CreateParameter(clsConstantsSP.ClsDAnodInspSP.ANGQTY, SqlDbType.Int, b.ANGQTY),
                    CreateParameter(clsConstantsSP.ClsDAnodInspSP.AOKQTY, SqlDbType.Int, b.AOKQTY),
                    CreateParameter(clsConstantsSP.ClsDAnodInspSP.Finished, SqlDbType.Bit, b.Finished),
                    CreateParameter(clsConstantsSP.ClsDAnodInspSP.MONo, SqlDbType.NVarChar, b.MONo),
                    CreateParameter(clsConstantsSP.ClsDAnodInspSP.Note, SqlDbType.NVarChar, b.Note),
                    CreateParameter(clsConstantsSP.ClsDAnodInspSP.StaffID, SqlDbType.NVarChar, b.StaffID)
                };
                Execute.DoInsert(clsConstantsFuction.ClsFuctionDAnodInsp.Insert, parameter, true);

            }
            catch (Exception e)
            {
                MessageBox.Show("" + e);
            }
        }
        public void InsertAnodQtyChangeDetail(clsAnodQtyChangeTable b)
        {

            try
            {
                var parameter = new SqlParameter[]
                {
                    CreateParameter(clsConstantsSP.ClsAnodQtyChangeSP.Date, SqlDbType.DateTime, b.Date),
                    CreateParameter(clsConstantsSP.ClsAnodQtyChangeSP.NGtoOKQty, SqlDbType.Int, b.NGtoOKQty),
                    CreateParameter(clsConstantsSP.ClsAnodQtyChangeSP.OKtoNGQty, SqlDbType.Int, b.OKtoNGQty),
                    CreateParameter(clsConstantsSP.ClsAnodQtyChangeSP.finished, SqlDbType.Bit, b.Finished),
                    CreateParameter(clsConstantsSP.ClsAnodQtyChangeSP.Mono, SqlDbType.NVarChar, b.Mono),
                    CreateParameter(clsConstantsSP.ClsAnodQtyChangeSP.note, SqlDbType.NVarChar, b.Note),
                    CreateParameter(clsConstantsSP.ClsAnodQtyChangeSP.StaffID, SqlDbType.NVarChar, b.StaffID)
                };
                Execute.DoInsert(clsConstantsFuction.ClsFuctionAnodQtyChange.Insert, parameter, true);

            }
            catch (Exception e)
            {
                MessageBox.Show("" + e);
            }
        }
        public void InsertBusInspDetail(ClsDBusInspTable b)
        {

            try
            {
                var parameter = new SqlParameter[]
                {
                    CreateParameter(clsConstantsSP.ClsDBusInspSP.Date, SqlDbType.DateTime, b.Date),
                    CreateParameter(clsConstantsSP.ClsDBusInspSP.BusQty, SqlDbType.Int, b.BusQty),
                    CreateParameter(clsConstantsSP.ClsDBusInspSP.Finished, SqlDbType.Bit, b.Finished),
                    CreateParameter(clsConstantsSP.ClsDBusInspSP.MONo, SqlDbType.NVarChar, b.MONo),
                    CreateParameter(clsConstantsSP.ClsDBusInspSP.Note, SqlDbType.NVarChar, b.Note),
                    CreateParameter(clsConstantsSP.ClsDBusInspSP.StaffID, SqlDbType.NVarChar, b.StaffID)
                };
                Execute.DoInsert(clsConstantsFuction.ClsFuctionDBusInsp.Insert, parameter, true);

            }
            catch (Exception e)
            {
                MessageBox.Show("" + e);
            }
        }
        public void InsertBusInspMisReturnDetail(ClsDMBusInspTable b)
        {

            try
            {
                var parameter = new SqlParameter[]
                {
                    CreateParameter(clsConstantsSP.ClsDMBusInspSP.date, SqlDbType.DateTime, b.Date),
                    CreateParameter(clsConstantsSP.ClsDMBusInspSP.RBusInspQty, SqlDbType.Int, b.RBusInspQty),
                    CreateParameter(clsConstantsSP.ClsDMBusInspSP.Finished, SqlDbType.Bit, b.Finished),
                    CreateParameter(clsConstantsSP.ClsDMBusInspSP.MONo, SqlDbType.NVarChar, b.MONo),
                    CreateParameter(clsConstantsSP.ClsDMBusInspSP.Note, SqlDbType.NVarChar, b.Note),
                    CreateParameter(clsConstantsSP.ClsDMBusInspSP.StaffID, SqlDbType.NVarChar, b.StaffID)
                };
                Execute.DoInsert(clsConstantsFuction.ClsFuctionDMBusInsp.Insert, parameter, true);

            }
            catch (Exception e)
            {
                MessageBox.Show("" + e);
            }
        }
        public void InsertF3StoreDetail(ClsDF3StoreTable b)
        {

            try
            {
                var parameter = new SqlParameter[]
                {
                    CreateParameter(clsConstantsSP.ClsDF3StoreSP.date, SqlDbType.DateTime, b.Date),
                    CreateParameter(clsConstantsSP.ClsDF3StoreSP.STNGQty, SqlDbType.Int, b.STNGQty),
                    CreateParameter(clsConstantsSP.ClsDF3StoreSP.STOKQTY, SqlDbType.Int, b.STOKQTY),
                    CreateParameter(clsConstantsSP.ClsDF3StoreSP.STSPQty, SqlDbType.Int, b.STSPQty),
                    CreateParameter(clsConstantsSP.ClsDF3StoreSP.Finished, SqlDbType.Bit, b.Finished),
                    CreateParameter(clsConstantsSP.ClsDF3StoreSP.MONo, SqlDbType.NVarChar, b.MONo),
                    CreateParameter(clsConstantsSP.ClsDF3StoreSP.Note, SqlDbType.NVarChar, b.Note),
                    CreateParameter(clsConstantsSP.ClsDF3StoreSP.StaffID, SqlDbType.NVarChar, b.StaffID)
                };
                Execute.DoInsert(clsConstantsFuction.ClsFuctionDF3Store.Insert, parameter, true);

            }
            catch (Exception e)
            {
                MessageBox.Show("" + e);
            }
        }
        public void InsertHandInspDetail(ClsDHandInspTable b)
        {

            try
            {
                var parameter = new SqlParameter[]
                {
                    CreateParameter(clsConstantsSP.ClsDHandInspSP.date, SqlDbType.DateTime, b.Date),
                    CreateParameter(clsConstantsSP.ClsDHandInspSP.NGQty, SqlDbType.Int, b.NGQty),
                    CreateParameter(clsConstantsSP.ClsDHandInspSP.OKQty, SqlDbType.Int, b.OKQty),
                    CreateParameter(clsConstantsSP.ClsDHandInspSP.Finished, SqlDbType.Bit, b.Finished),
                    CreateParameter(clsConstantsSP.ClsDHandInspSP.MONo, SqlDbType.NVarChar, b.MONo),
                    CreateParameter(clsConstantsSP.ClsDHandInspSP.Note, SqlDbType.NVarChar, b.Note),
                    CreateParameter(clsConstantsSP.ClsDHandInspSP.StaffID, SqlDbType.NVarChar, b.StaffID)
                };
                Execute.DoInsert(clsConstantsFuction.ClsFuctionDHandInsp.Insert, parameter, true);

            }
            catch (Exception e)
            {
                MessageBox.Show("" + e);
            }
        }
        public void InsertHandInspMisReturnDetail(ClsDMHandInspTable b)
        {

            try
            {
                var parameter = new SqlParameter[]
                {
                    CreateParameter(clsConstantsSP.ClsDMHandInspSP.Date, SqlDbType.DateTime, b.Date),
                    CreateParameter(clsConstantsSP.ClsDMHandInspSP.RNGQty, SqlDbType.Int, b.RNGQty),
                    CreateParameter(clsConstantsSP.ClsDMHandInspSP.ROKQty, SqlDbType.Int, b.ROKQty),
                    CreateParameter(clsConstantsSP.ClsDMHandInspSP.Finished, SqlDbType.Bit, b.Finished),
                    CreateParameter(clsConstantsSP.ClsDMHandInspSP.MONo, SqlDbType.NVarChar, b.MONo),
                    CreateParameter(clsConstantsSP.ClsDMHandInspSP.Note, SqlDbType.NVarChar, b.Note),
                    CreateParameter(clsConstantsSP.ClsDMHandInspSP.StaffID, SqlDbType.NVarChar, b.StaffID)
                };
                Execute.DoInsert(clsConstantsFuction.ClsFuctionDMHandInsp.Insert, parameter, true);

            }
            catch (Exception e)
            {
                MessageBox.Show("" + e);
            }
        }
        //   InsertHandInspStatus
        //public void InsertHandInspStatus(ClsDMHandInspTable b)
        //{

        //    try
        //    {
        //        var parameter = new SqlParameter[]
        //        {
        //            CreateParameter(clsConstantsSP.ClsDMHandInspSP.Date, SqlDbType.DateTime, b.Date),
        //            CreateParameter(clsConstantsSP.ClsDMHandInspSP.RNGQty, SqlDbType.Int, b.RNGQty),
        //            CreateParameter(clsConstantsSP.ClsDMHandInspSP.ROKQty, SqlDbType.Int, b.ROKQty),
        //            CreateParameter(clsConstantsSP.ClsDMHandInspSP.Finished, SqlDbType.Bit, b.Finished),
        //            CreateParameter(clsConstantsSP.ClsDMHandInspSP.MONo, SqlDbType.NVarChar, b.MONo),
        //            CreateParameter(clsConstantsSP.ClsDMHandInspSP.Note, SqlDbType.NVarChar, b.Note),
        //            CreateParameter(clsConstantsSP.ClsDMHandInspSP.StaffID, SqlDbType.NVarChar, b.StaffID)
        //        };
        //        Execute.DoDelete(clsConstantsFuction.ClsFuctionDMHandInsp.Insert, parameter, true);

        //    }
        //    catch (Exception e)
        //    {
        //        MessageBox.Show("" + e);
        //    }
        //}
        public void InsertInspAnodDetail(ClsDInspAnodTable b)
        {

            try
            {
                var parameter = new SqlParameter[]
                {
                    CreateParameter(clsConstantsSP.ClsDInspAnodSP.date, SqlDbType.DateTime, b.Date),
                    CreateParameter(clsConstantsSP.ClsDInspAnodSP.INGQty, SqlDbType.Int, b.INGQty),
                    CreateParameter(clsConstantsSP.ClsDInspAnodSP.IOKQty, SqlDbType.Int, b.IOKQty),
                    CreateParameter(clsConstantsSP.ClsDInspAnodSP.Finished, SqlDbType.Bit, b.Finished),
                    CreateParameter(clsConstantsSP.ClsDInspAnodSP.MONo, SqlDbType.NVarChar, b.MONo),
                    CreateParameter(clsConstantsSP.ClsDInspAnodSP.Note, SqlDbType.NVarChar, b.Note),
                    CreateParameter(clsConstantsSP.ClsDInspAnodSP.StaffID, SqlDbType.NVarChar, b.StaffID)
                };
                Execute.DoInsert(clsConstantsFuction.ClsFuctionDInspAnod.Insert, parameter, true);

            }
            catch (Exception e)
            {
                MessageBox.Show("" + e);
            }
        }
        public void InsertInspBusMisReturnDetail(ClsDMInspBusTable b)
        {

            try
            {
                var parameter = new SqlParameter[]
                {
                    CreateParameter(clsConstantsSP.ClsDMInspBusSP.date, SqlDbType.DateTime, b.Date),
                    CreateParameter(clsConstantsSP.ClsDMInspBusSP.RInspBusQty, SqlDbType.Int, b.RInspBusQty),
                    CreateParameter(clsConstantsSP.ClsDMInspBusSP.Finished, SqlDbType.Bit, b.Finished),
                    CreateParameter(clsConstantsSP.ClsDMInspBusSP.MONo, SqlDbType.NVarChar, b.MONo),
                    CreateParameter(clsConstantsSP.ClsDMInspBusSP.note, SqlDbType.NVarChar, b.Note),
                    CreateParameter(clsConstantsSP.ClsDMInspBusSP.StaffID, SqlDbType.NVarChar, b.StaffID)
                };
                Execute.DoInsert(clsConstantsFuction.ClsFuctionDMInspBus.Insert, parameter, true);

            }
            catch (Exception e)
            {
                MessageBox.Show("" + e);
            }
        }
        public void InsertInspF3Detail(ClsDInspF3Table b)
        {

            try
            {
                var parameter = new SqlParameter[]
                {
                    CreateParameter(clsConstantsSP.ClsDInspF3SP.date, SqlDbType.DateTime, b.Date),
                    CreateParameter(clsConstantsSP.ClsDInspF3SP.F3NGQty, SqlDbType.Int, b.F3NGQty),
                    CreateParameter(clsConstantsSP.ClsDInspF3SP.F3OKQty, SqlDbType.Int, b.F3OKQty),
                    CreateParameter(clsConstantsSP.ClsDInspF3SP.F3SPQty, SqlDbType.Int, b.F3SPQty),
                    CreateParameter(clsConstantsSP.ClsDInspF3SP.Finished, SqlDbType.Bit, b.Finished),
                    CreateParameter(clsConstantsSP.ClsDInspF3SP.MONo, SqlDbType.NVarChar, b.MONo),
                    CreateParameter(clsConstantsSP.ClsDInspF3SP.Note, SqlDbType.NVarChar, b.Note),
                    CreateParameter(clsConstantsSP.ClsDInspF3SP.StaffID, SqlDbType.NVarChar, b.StaffID)
                };
                Execute.DoInsert(clsConstantsFuction.ClsFuctionDInspF3.Insert, parameter, true);

            }
            catch (Exception e)
            {
                MessageBox.Show("" + e);
            }
        }
        public void InsertInspHandMisReturnDetail(ClsDMInspHandTable b)
        {

            try
            {
                var parameter = new SqlParameter[]
                {
                    CreateParameter(clsConstantsSP.ClsDMInspHandSP.date, SqlDbType.DateTime, b.Date),
                    CreateParameter(clsConstantsSP.ClsDMInspHandSP.RQty, SqlDbType.Int, b.RQty),
                    CreateParameter(clsConstantsSP.ClsDMInspHandSP.Finished, SqlDbType.Bit, b.Finished),
                    CreateParameter(clsConstantsSP.ClsDMInspHandSP.MONo, SqlDbType.NVarChar, b.MONo),
                    CreateParameter(clsConstantsSP.ClsDMInspHandSP.Note, SqlDbType.NVarChar, b.Note),
                    CreateParameter(clsConstantsSP.ClsDMInspHandSP.StaffID, SqlDbType.NVarChar, b.StaffID)
                };
                Execute.DoInsert(clsConstantsFuction.ClsFuctionDMInspHand.Insert, parameter, true);

            }
            catch (Exception e)
            {
                MessageBox.Show("" + e);
            }
        }
        public void InsertMAchineHandDetail(ClsDMachineHandTable b)
        {

            try
            {
                var parameter = new SqlParameter[]
                {
                    CreateParameter(clsConstantsSP.ClsDMachineHandSP.Date, SqlDbType.DateTime, b.Date),
                    CreateParameter(clsConstantsSP.ClsDMachineHandSP.NGQty, SqlDbType.Int, b.NGQty),
                    CreateParameter(clsConstantsSP.ClsDMachineHandSP.OKQty, SqlDbType.Int, b.OKQty),
                    CreateParameter(clsConstantsSP.ClsDMachineHandSP.Finished, SqlDbType.Bit, b.Finished),
                    CreateParameter(clsConstantsSP.ClsDMachineHandSP.MONo, SqlDbType.NVarChar, b.MONo),
                    CreateParameter(clsConstantsSP.ClsDMachineHandSP.Note, SqlDbType.NVarChar, b.Note),
                    CreateParameter(clsConstantsSP.ClsDMachineHandSP.StaffID, SqlDbType.NVarChar, b.StaffID)
                };
                Execute.DoInsert(clsConstantsFuction.ClsFuctionDMachineHand.Insert, parameter, true);

            }
            catch (Exception e)
            {
                MessageBox.Show("" + e);
            }
        }

        //lấy dữ liệu điều kiện check lỗi
        public DataTable GetMachHandMO(string MONo)
        {
            string sql = clsConstantsFuction.ClsFuctionDMInspHand.GetMachHandMO;
            var parameter = new SqlParameter[]
                {
                    CreateParameter("@MONo", SqlDbType.NVarChar, MONo)
                };
            return Execute.DoStoreGetByID(sql,parameter, true);
        }

        public DataTable GetMachHandMO02(string MONo)
        {
            string sql = clsConstantsFuction.ClsFuctionDMInspHand.GetMachHandMO02;
            var parameter = new SqlParameter[]
                {
                    CreateParameter("@MONo", SqlDbType.NVarChar, MONo)
                };
            return Execute.DoStoreGetByID(sql, parameter, true);
        }

        public DataTable GetInspHandMO(string MONo)
        {
            string sql = clsConstantsFuction.ClsFuctionDMInspHand.GetInspHandMO;
            var parameter = new SqlParameter[]
                {
                    CreateParameter("@MONo", SqlDbType.NVarChar, MONo)
                };
            return Execute.DoStoreGetByID(sql, parameter, true);
        }

        public DataTable GetBusInsp(string MONo)
        {
            string sql = clsConstantsFuction.ClsFuctionDMInspHand.GetBusInsp;
            var parameter = new SqlParameter[]
                {
                    CreateParameter("@MONo", SqlDbType.NVarChar, MONo)
                };
            return Execute.DoStoreGetByID(sql, parameter, true);
        }
    }
}
